<?php /* Smarty version Smarty-3.0.8, created on 2014-11-03 19:12:43
         compiled from "tpl/js/controller/login.js" */ ?>
<?php /*%%SmartyHeaderCode:287135457632b03b890-47902682%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'fef2cbbef08eea136088bfbec7205b74f364187c' => 
    array (
      0 => 'tpl/js/controller/login.js',
      1 => 1410828306,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '287135457632b03b890-47902682',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
//登录
App.controller('login', function (page) {
  $(page).on("appReady",function(){
      $.get( url("user","logout") );
      $("#stuid").val(kget("studentid"));
  });
  $(page).find(".ptime-button").on("touchstart",function(){
    $(this).addClass('active');
  }).on("touchend",function(){
    $(this).removeClass('active');
  });
  $(page).find(".ptime-school li.app-checkbox").on("tap",function(){
    $(page).find(".ptime-school li.app-checkbox").removeClass("selected");
    $(this).addClass('selected');
  });
  $(page).find(".ptime-status li.app-checkbox").on("tap",function(){
    $(page).find(".ptime-status li.app-checkbox").removeClass("selected");
    $(this).addClass('selected');
  });
  $(page).find("#ptime-login-button").on("tap",function(){
    
    var v_this = $(this);
    var stuid=$("#stuid").val();
    var stupw=$("#stupw").val();
    var session_id=$("#session_id").val();
    var verify_code=$("#verify_code").val();
    
    loading.start("登录中");
    $.post( url("user","login"), {stuid:stuid,stupw:stupw,session_id:session_id,verify_code:verify_code}, function(data){
      loading.end();
      if(typeof(data.id) != "undefined"){
        kset("id",data.id);
        kset("studentid",data.studentid);
        kset("username",data.username);
        App.load("my-time-content");
      }else{
        alert(data.errmsg);
        if(data.errcode=="first_login"){
          loading.start("验证码获取中");
          $.get( url("user","login_first_graducated_pre"),function(data){
            loading.end();
            if(typeof(data.errmsg) != "undefined"){
              alert(data.errmsg);
            }else{
              $('#session_id').val(data.session_id);
              $('img#verify_img').attr('src',data.pic_path);
              $('#verify_box').show();
            }
          },"json");
        }
      }
    },"json");
  });
});